A unit of work (UW) contains database statements. The UW is to be executed by a Database Management System (DBMS) against a database (DB), and upon execution of the UW, changes may be made to the contents of the DB.
Some DBMSs may include a database transaction manager (DBTM). The DBTM may be used to process the UW before that UW is passed onto the DBMS. Examples of DBTM commands are the BEGIN statement, the COMMIT statement and the ROLLBACK statement. The BEGIN statement notifies the DBTM that the UW will begin with a DB statement which immediately follows the BEGIN statement. The COMMIT statement directs the DBTM to pass on all database statements contained in the UW to the DBMS so that the DBMS may then execute the database statements contained in the UW. The ROLLBACK statement directs the DBTM to remove some or all of the database statements contained in the UW before the UW may then be COMMITTED (by use of the COMMIT statement). The DBTM may store the collection of database statements of the UW in a transaction log file (for example, a buffer). The ROLLBACK statement directs the DBTM to edit the UW, and then the COMMIT statement may be used to direct the DBTM to forward the edited WU over to the DBMS for subsequent execution against the DB.
The DBTM may be non-integrated with the DBMS or the DBTM may be integrated with the DBMS. The ROLLBACK statement may be embedded in an application program or it may be issued through the use of dynamic SQL statements as known in the art (that is, it may be an executable statement that may be dynamically prepared). The ROLLBACK statement may direct the DBMS to back out of database statements included in the UW (thereby effectively removing rolled back database statements to a preferred point or location in the UW.
Another DBTM statement is a SAVEPOINT statement which directs the DBTM to insert a savepoint within the UW. The savepoint statement may be included in an application program (including a stored procedure) or may be issued interactively to the DBTM (as known in the art). The savepoint statement may also be an executable statement that may be dynamically prepared. The savepoint which becomes inserted into the UW becomes a marker within the UW. This is for the convenience of the user so that any database statements inserted after the savepoint may be rolled back to the savepoint if and when it is deemed necessary to do so by the user.
Some ROLLBACK statements may be used to direct the DBTM to roll back database statements made after the savepoint. Executing this type of ROLLBACK statement may result in a partial rollback (that is, roll back to a savepoint) of the database statements contained in the UW.
A problem exists when boundary generators are inserted into the UW between a savepoint and the ROLLBACK statement which directs the DBTM to roll back past the boundary generator to the savepoint. Some types of boundary generators may not be rolled past and some other types of may be rolled past. Executing the “partial” ROLLBACK statement in the presence of a boundary generator that does not permit any rolling back past the boundary generator may lead to unpredictable results or errors in the UW, which in turn when the UW is executed against the DB, the DB may become disadvantageously ruined altogether.
What is needed is a solution to the above described problem.